package com.fyzk.activity.lottery.zc_new.adapter;


import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fyzk.bean.ZCGameQueueItem;
import com.tyjc.lottery.R;
import com.fyzk.utils.TextStyleUtil;

import java.util.List;

public class ZCBQCAdapter_New extends ZCBaseAdapter{

	public ZCBQCAdapter_New(Context context, List<ZCGameQueueItem> infors) {
		super(context, infors);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected View getRightView(final ZCGameQueueItem data, int position) {
		// TODO Auto-generated method stub
		View rightView = LayoutInflater.from(context).inflate(R.layout.zc_adapter_bqc, null);
		TextView home_tv =  (TextView) rightView.findViewById(R.id.zc_bqc_home);
		TextView away_tv = (TextView) rightView.findViewById(R.id.zc_bqc_away);
		CheckBox ban_sheng_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_ban_sheng);
		CheckBox ban_ping_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_ban_ping);
		CheckBox ban_fu_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_ban_fu);
		CheckBox quan_sheng_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_quan_sheng);
		CheckBox quan_ping_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_quan_ping);
		CheckBox quan_fu_check = (CheckBox) rightView.findViewById(R.id.zc_bqc_quan_fu);
		
		home_tv.setText(data.getHomeTeam());
		away_tv.setText(data.getAwayTeam());
		
		ban_sheng_check.setChecked(data.isBanSheng);
		ban_ping_check.setChecked(data.isBanPing);
		ban_fu_check.setChecked(data.isBanFu);
		quan_sheng_check.setChecked(data.isQuanSheng);
		quan_ping_check.setChecked(data.isQuanPing);
		quan_fu_check.setChecked(data.isQuanFu);
		

	    SpannableString spanString = TextStyleUtil.fontSizeSpan(new SpannableString("3 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    ban_sheng_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getHalf_3()+")"), 12);
	    ban_sheng_check.append(spanString);

	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("1 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    ban_ping_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getHalf_1()+")"), 12);
	    ban_ping_check.append(spanString);

	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("0 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    ban_fu_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getHalf_0()+")"), 12);
	    ban_fu_check.append(spanString);


	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("3 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    quan_sheng_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getFull_3()+")"), 12);
	    quan_sheng_check.append(spanString);

	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("1 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    quan_ping_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getFull_1()+")"), 12);
	    quan_ping_check.append(spanString);

	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString("0 "), 18);
	    spanString = TextStyleUtil.styleSpan(spanString, Typeface.BOLD);
	    quan_fu_check.append(spanString);
	    spanString = TextStyleUtil.fontSizeSpan(new SpannableString(" ("+data.getFull_0()+")"), 12);
	    quan_fu_check.append(spanString);
	    
		
		ban_sheng_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isBanSheng = ! data.isBanSheng;
				if (data.isBanSheng) {
					data.ban_clickNum++;
				}else{
					data.ban_clickNum--;
				}
				tongJi();
			}
		});
		
		ban_ping_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isBanPing = ! data.isBanPing;
				if (data.isBanPing) {
					data.ban_clickNum++;
				}else{
					data.ban_clickNum--;
				}
				tongJi();
			}
		});
		
		ban_fu_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isBanFu = ! data.isBanFu;
				if (data.isBanFu) {
					data.ban_clickNum++;
				}else{
					data.ban_clickNum--;
				}
				tongJi();
			}
		});
		
		
		quan_sheng_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isQuanSheng = ! data.isQuanSheng;
				if (data.isQuanSheng) {
					data.quan_clickNum++;
				}else{
					data.quan_clickNum--;
				}
				tongJi();
			}
		});
		
		quan_ping_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isQuanPing = ! data.isQuanPing;
				if (data.isQuanPing) {
					data.quan_clickNum++;
				}else{
					data.quan_clickNum--;
				}
				tongJi();
			}
		});
		
		quan_fu_check.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				data.isQuanFu = ! data.isQuanFu;
				if (data.isQuanFu) {
					data.quan_clickNum++;
				}else{
					data.quan_clickNum--;
				}
				tongJi();
			}
		});
		
		LinearLayout.LayoutParams pl = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
				LayoutParams.MATCH_PARENT, 1);
		rightView.setLayoutParams(pl);
		return rightView;
	}

}
